﻿using Common;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
	public partial class s : System.Web.UI.Page
	{
		protected string JsonFile { get; set; }

		[DllImport("shell32.dll ")]
		public static extern int ShellExecute(IntPtr hwnd, StringBuilder lpszOp, StringBuilder lpszFile, StringBuilder lpszParams, StringBuilder lpszDir, int FsShowCmd);
		protected void Button1_Click(object sender, EventArgs e)
		{
			var config = GetCrawlerConfig();

			ShellExecute(IntPtr.Zero, new StringBuilder("Open"), new StringBuilder(config.CrawlerExe), new StringBuilder(this.TextBox1.Text), new StringBuilder(""), 1);
		}
		private CrawlerConfig GetCrawlerConfig()
		{
			var filePath = Server.MapPath("~/Config/config.json");
			return System.IO.File.ReadAllText(filePath, Encoding.GetEncoding("gbk")).DeserializeObject<CrawlerConfig>();

		}




		protected void Page_Load(object sender, EventArgs e)
		{
		}
	}
}